Fix passive popup/tab registration in the Node bridge server#104
Open
poman wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes playwright-php/playwright-mink#4
BrowserContext/the PHP client already handle a"page"event coming from the server (a new page/tab was created by the browser) and dispatch it correctly once received. The Node server, however, never subscribed to the underlying Playwrightcontext.on('page', ...)event, so the event was never sent over the wire in the first place. Any workflow that opens a second tab/window from the page itself (window.open(),target="_blank", ...) — as opposed to a tab created through an explicitwaitForPopup()/waitForEvent('page')call — was invisible to the PHP side: driver code that clicks a link and only afterwards inspects the set of open windows (the pattern Mink-based drivers use) never saw the new tab.Adds a
registerContextPopups()subscription right after each of the four places that create and register aBrowserContext(launchBrowser,newContext,connect,connectOverCDP). It forwards a"page"event with the new page's ID once it settles, deduplicated against pages already registered through the existing explicit paths (createNewPage(),waitForEvent('page'),waitForPopup()) so the same page is never registered twice.Testing
tests/Integration/Popup/PassivePopupDiscoveryTest.php: clicks atarget="_blank"link with nowaitForPopup()/waitForEvent('page')armed beforehand, and asserts the new page shows up inBrowserContext::pages()— verified it fails against the pre-fix server (stays at 1 page) and passes with the fix (reaches 2).tests/Integration/Popup/*, 8 tests) to confirm the passive subscription does not double-register pages already handled bywaitForPopup()/waitForEvent('page')/createNewPage()— all green.php-cs-fixer --dry-runclean;phpstan analyse(level 10) reports 0 errors on the changed/added files;node --checkon the modified server file.Discovered while running the OroCommerce Behat regression suite on the Mink driver built on top of this library - the same root cause as playwright-php/playwright-mink#4